package com.leige.utils;


import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;

@Component("jedismessage")
public class JedisMessage{
	private static Logger logger = LoggerFactory.getLogger(JedisMessage.class);
	@Resource(name="redistemplate")
	private RedisTemplate<String,Object>  redistemplate;
	public void setRedistemplate(RedisTemplate<String, Object> redistemplate) {
		this.redistemplate = redistemplate;
	}
	private int i = 0;

	@Scheduled(cron = "0/10 * * * * ?")
	public void Send() {
		String[] str=new String[]{"abc","def"};
		redistemplate.convertAndSend("a",  str);
	}
	
	public void out(String[] msg ){
		System.err.println(JSON.toJSONString(msg));
		ListOperations<String, Object> opslist = redistemplate.opsForList();
		System.out.println(opslist.leftPush("abc", 555));
	}
}
